<?php
/**
 * Created by PhpStorm.
 * User: Think
 * Date: 2018/4/4
 * Time: 11:23
 */

namespace app\index\controller;

use think\Db;
use think\Request;
use think\Controller;

class Api extends Controller
{
    public function domain()
    {
//        查询域名是否被注册
        $domain = "souxun1234.com";
        $cha = 'http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=' . $domain;
        $fp = file_get_contents($cha, 'rb');

        $xml = simplexml_load_string($fp);
        $data = json_decode(json_encode($xml), TRUE);
        $this->assign('name', '<h1>Rinuo</h1>');
        $this->assign('data', $data);
        return $this->fetch();
    }

    public function demo()
    {
        $url = "http://easytp5.com/index/bbs/add";
        $data = ['title' => '35api 测试一下', 'content' => '测试2018年4月4日15:38:23'];
//       1.初始化
        $ch = curl_init();
//        2  设置选项,包括url
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//        3 执行并获取html文档内容
        $output = curl_exec($ch);
//        4 释放curl句柄
        curl_close($ch);
//        return $output;
    }
}


